// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: jshin

#pragma once

#include <cstdint>

namespace coin2::exchange::base::executor {

class LifecycleTimestamp {
 public:
  LifecycleTimestamp() {}
  ~LifecycleTimestamp() {}

  int64_t exchange_transact_timestamp() const { return exchange_transact_timestamp_; }
  int64_t exchange_publish_timestamp() const { return exchange_publish_timestamp_; }
  int64_t raw_rx_timestamp() const { return raw_rx_timestamp_; }
  int64_t raw_tx_timestamp() const { return raw_tx_timestamp_; }
  int64_t parser_rx_timestamp() const { return parser_rx_timestamp_; }
  int64_t parser_tx_timestamp() const { return parser_tx_timestamp_; }
  int64_t main_rx_timestamp() const { return main_rx_timestamp_; }
  int64_t main_tx_timestamp() const { return main_tx_timestamp_; }
  int64_t exhaust_rx_timestamp() const { return exhaust_rx_timestamp_; }
  int64_t exhaust_tx_timestamp() const { return exhaust_tx_timestamp_; }

  int64_t pre_read_available() const { return pre_read_available_; }
  int64_t pre_read_timestamp() const { return pre_read_timestamp_; }
  int64_t post_read_available() const { return post_read_available_; }
  int64_t post_read_timestamp() const { return post_read_timestamp_; }

  void set_exchange_transact_timestamp(int64_t timestamp) {
    exchange_transact_timestamp_ = timestamp;
  }
  void set_exchange_publish_timestamp(int64_t timestamp) {
    exchange_publish_timestamp_ = timestamp;
  }
  void set_raw_rx_timestamp(int64_t timestamp) { raw_rx_timestamp_ = timestamp; }
  void set_raw_tx_timestamp(int64_t timestamp) { raw_tx_timestamp_ = timestamp; }
  void set_parser_rx_timestamp(int64_t timestamp) { parser_rx_timestamp_ = timestamp; }
  void set_parser_tx_timestamp(int64_t timestamp) { parser_tx_timestamp_ = timestamp; }
  void set_main_rx_timestamp(int64_t timestamp) { main_rx_timestamp_ = timestamp; }
  void set_main_tx_timestamp(int64_t timestamp) { main_tx_timestamp_ = timestamp; }
  void set_exhaust_rx_timestamp(int64_t timestamp) { exhaust_rx_timestamp_ = timestamp; }
  void set_exhaust_tx_timestamp(int64_t timestamp) { exhaust_tx_timestamp_ = timestamp; }

  void set_pre_read_available(int64_t available) { pre_read_available_ = available; }
  void set_pre_read_timestamp(int64_t timestamp) { pre_read_timestamp_ = timestamp; }
  void set_post_read_available(int64_t available) { post_read_available_ = available; }
  void set_post_read_timestamp(int64_t timestamp) { post_read_timestamp_ = timestamp; }

  void Reset() {
    exchange_transact_timestamp_ = 0;
    exchange_publish_timestamp_ = 0;
    raw_rx_timestamp_ = 0;
    raw_tx_timestamp_ = 0;
    parser_rx_timestamp_ = 0;
    parser_tx_timestamp_ = 0;
    main_rx_timestamp_ = 0;
    main_tx_timestamp_ = 0;
    exhaust_rx_timestamp_ = 0;
    exhaust_tx_timestamp_ = 0;
  }

 protected:
  int64_t exchange_transact_timestamp_{0};
  int64_t exchange_publish_timestamp_{0};
  int64_t raw_rx_timestamp_{0};
  int64_t raw_tx_timestamp_{0};
  int64_t parser_rx_timestamp_{0};
  int64_t parser_tx_timestamp_{0};
  int64_t main_rx_timestamp_{0};
  int64_t main_tx_timestamp_{0};
  int64_t exhaust_rx_timestamp_{0};
  int64_t exhaust_tx_timestamp_{0};

  // Pre-read and post-read stats.
  int64_t pre_read_available_{0};
  int64_t pre_read_timestamp_{0};
  int64_t post_read_available_{0};
  int64_t post_read_timestamp_{0};
};

}  // namespace coin2::exchange::base::executor
